//
//  SuccedTixianViewController.m
//  customer
//
//  Created by 往返网络 on 17/8/24.
//  Copyright © 2017年 com. All rights reserved.
//

#import "SuccedTixianViewController.h"
#define return_tag 1000
#define complte_tag 1001

@interface SuccedTixianViewController ()

@end

@implementation SuccedTixianViewController

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = YES;
    self.tabBarController.tabBar.hidden = YES;
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createUI];
    // Do any additional setup after loading the view.
}
- (void)createUI{
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    float fontsize = 17;
    
    fontsize = SCREEN_H < 667 ? 15 : 19;
    
    if (SCREEN_H == 667) {
        
        fontsize = 17;
    }
    self.view.backgroundColor = COLORRGBA(239, 239, 239, 1);
    //设置表头
    UIView * titleview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_W, 128.0/1334*SCREEN_H)];
    
    titleview.backgroundColor = COLORRGBA(7, 24, 57, 1);
    
    [self.view addSubview:titleview];
    
    //title
    UILabel * titlelab = [[UILabel alloc]initWithFrame:CGRectMake(0, 20.0, SCREEN_W, 90.0/H_BASE*SCREEN_H)];
    titlelab.text = @"提现";
    titlelab.textColor = [UIColor whiteColor];
    [self.view addSubview:titlelab];
    titlelab.textAlignment = NSTextAlignmentCenter;
    titlelab.font = [UIFont systemFontOfSize:fontsize];
    
    UILabel * leftlable  = [[UILabel alloc]initWithFrame:CGRectMake(0, 20+14.0/1334*SCREEN_H, 150.0/W_BASE*SCREEN_W, 60.0/1334.0*SCREEN_H)];
    leftlable.textAlignment = NSTextAlignmentCenter;
    NSString * endstr = @"\U0000e697";
    NSString * text = [NSString stringWithFormat:@"%@%@",endstr,@"返回"];
    leftlable.attributedText = [self changeLabelWithText2:text andStartplace:endstr andendplae:nil andfontsize:fontsize-2];
    leftlable.textColor = [UIColor whiteColor];
    [self.view addSubview:leftlable];
    
    UIButton * returnbtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 150.0/W_BASE*SCREEN_W, 150.0/H_BASE*SCREEN_H)];
    [returnbtn addTarget:self action:@selector(enterClick:) forControlEvents:UIControlEventTouchUpInside];
    returnbtn.tag = return_tag;
    [self.view addSubview:returnbtn];
    
    UIView * backview = [[UIView alloc]initWithFrame:CGRectMake(0, 127.0/H_BASE*SCREEN_H, SCREEN_W, SCREEN_H-127.0/H_BASE*SCREEN_H)];
    backview.backgroundColor = COLORRGBA(239, 239, 239, 1);
    [self.view addSubview:backview];
    
    UIView * view1 = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(titleview.frame), SCREEN_W, 300.0/H_BASE*SCREEN_H)];
    view1.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:view1];
    
    UILabel * statuslab = [[UILabel alloc]initWithFrame:CGRectMake(0, 60.0/H_BASE*SCREEN_H, SCREEN_W, 60.0/H_BASE*SCREEN_H)];
    statuslab.text = @"提现成功";
    statuslab.font = [UIFont systemFontOfSize:fontsize];
    statuslab.textColor = COLORRGBA(38, 146, 255, 1);
    [view1 addSubview:statuslab];
    statuslab.textAlignment = NSTextAlignmentCenter;
    
    UILabel * daozhanglab = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(statuslab.frame), SCREEN_W, 60.0/H_BASE*SCREEN_H)];
    daozhanglab.text = @"预计2小时内到账";
    daozhanglab.font = [UIFont systemFontOfSize:fontsize-2];
    daozhanglab.textColor = COLORRGBA(153, 153, 153, 1);
    [view1 addSubview:daozhanglab];
    daozhanglab.textAlignment = NSTextAlignmentCenter;
    
    UILabel * numlab = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(daozhanglab.frame), SCREEN_W, 60.0/H_BASE*SCREEN_H)];
    numlab.text = [NSString stringWithFormat:@"%@元",self.jinestring];
    numlab.font = [UIFont systemFontOfSize:fontsize+11];
    numlab.textColor = [UIColor blackColor];
    [view1 addSubview:numlab];
    numlab.textAlignment = NSTextAlignmentCenter;
    
    UIButton * completbtn = [[UIButton alloc]initWithFrame:CGRectMake(30.0/W_BASE*SCREEN_W, CGRectGetMaxY(view1.frame)+50.0/H_BASE*SCREEN_H, SCREEN_W-60.0/W_BASE*SCREEN_W, 80.0/H_BASE*SCREEN_H)];
    completbtn.backgroundColor = COLORRGBA(59, 214, 117, 1);
    [completbtn setTitle:@"完成" forState:UIControlStateNormal];
    [completbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [completbtn addTarget:self action:@selector(enterClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:completbtn];
    completbtn.layer.cornerRadius = 2;
    completbtn.clipsToBounds = YES;
    completbtn.titleLabel.font = [UIFont systemFontOfSize:fontsize-2];
    completbtn.tag = complte_tag;
    
    
}

#pragma mark  -  -  起始地＋发货人名（终止地＋收货人名）格式化 － － －-- - -  -

-(NSMutableAttributedString*)changeLabelWithText2:(NSString*)needText andStartplace:(NSString *)startplace andendplae:(NSString *)endplace andfontsize:(float)fontsize
{
    NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:needText];
    NSInteger startlength = startplace.length;
    //起始格式化
    [attrString addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"iconfont" size:fontsize+2] range:NSMakeRange(0,startlength)];
    //    //尾部格式化
    [attrString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:fontsize] range:NSMakeRange(startlength , needText.length  - startlength)];
    return attrString;
}

#pragma mark - - - - - - - - - - -  Action - - - - - - - - - - - - -
- (void)enterClick:(UIButton *)btn{
    
    switch (btn.tag) {
        case return_tag:
            //返回
            //发送主页刷新余额通知
            [[NSNotificationCenter defaultCenter]postNotificationName:@"REFRESH" object:nil];

            [self.navigationController popViewControllerAnimated:YES];
            
            break;
            
        case complte_tag:
            //完成，直接回到主页面
            //发送主页刷新余额通知
            [[NSNotificationCenter defaultCenter]postNotificationName:@"REFRESH" object:nil];

            [self.navigationController popToRootViewControllerAnimated:YES];
            
            break;
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
